import pyecharts as pye
import random
timeline = pye.charts.Timeline()
for x in range(2004,2025):
    bar1 = pye.charts.Bar()
    bar1.add_xaxis(['张景红','张景绿','张景黑'])
    bar1.add_yaxis("劳力",[random.randint(10,1000),random.randint(10,1000),random.randint(10,1000)],label_opts=pye.options.LabelOpts(position="right",color="red"))
    bar1.reversal_axis()# 反转X和Y轴
    timeline.add(bar1,str(x) +"年")
timeline.add_schema(
    play_interval=500,# 播放速度
    is_loop_play=False# 循环播放
)
timeline.render("柱状图-时间轴.html")